﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using Fan.Dongping.Common.DBMeta;
using Fan.Dongping.Common.Bean;
using Fan.Dongping.DataAccess;
using System.Collections.Generic;
using Fan.Dongping.Common;

/// <summary>
/// Summary description for LineUtils
/// </summary>
public class LineUtils
{
    public static List<WorkflowLine> GetLines(string workflowId)
    {
        List<WorkflowLine> lines = new List<WorkflowLine>();
        DataTable dt = LineDA.GetWorkflowLines(workflowId);
        foreach (DataRow var in dt.Rows)
        {
            WorkflowLine line = new WorkflowLine();

            int l = (int)var[WorkflowLineMeta.LeftField];
            int t = (int)var[WorkflowLineMeta.TopField];
            int r = (int)var[WorkflowLineMeta.ArrowField];
            int w = (int)var[WorkflowLineMeta.WidthField];
            int h = (int)var[WorkflowLineMeta.HeightField];

            Point a = new Point(l, t + 10);
            line.A = a;
            if (r == -1)
            {
                line.HaveArrow = false;
            }
            else
            {
                line.HaveArrow = true;
            }

            if (w > h)
            {
                Point b = new Point(l + w, t + 10);
                line.B = b;
                line.ArrowDirection = Direct.Right;
            }
            else
            {
                Point b = new Point(l, t + h - 10);
                line.B = b;
                line.ArrowDirection = Direct.Downward;
            }

            lines.Add(line);
        }
        return lines;
    }
}
